<meta content="telephone=no" name="format-detection" />
<title>{$sys_name} - 交易大厅</title>
<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.min.css" rel="stylesheet">
    <link href="/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="/css/plugins/treeview/bootstrap-treeview.css" rel="stylesheet">
    <!-- Bootstrap -->
    <link href="/css/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/css/reset.css" rel="stylesheet">
    <link href="/css/css/style.css" rel="stylesheet">

    <script src="/js/js/jquery-1.11.3.min.js" type="text/javascript"></script>
    <script src="/js/js/respond.js" type="text/javascript"></script>
    <script src="/js/js/common.js" type="text/javascript"></script>
    <script src="/js/js/bootstrap-datetimepicker.min.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body class="bg">
<include file="Public/Home/confirm.html" />
<!--头部-->
<include file="Public/Home/Pubheader.html" />
<section class="wrapper" style="padding:0">
    <!--左侧导航-->
    <include file="Public/Home/Menu.html" />

    <div class="content-area">
        <div class="t80"></div>
        <div class="z_top">
            <div class="location">
                <img src="images/location.png" alt="">
                <span>{$lang.ur_here}：交易大厅</span>
            </div>
        </div>
        <div class="content">
            <div class="main_top bq_bg" >
                <div class="font18 f2">
                    <img src="images/top_icon3.png" alt="">
                    <p style="width: 70%;font-size: 14px">
                        {$B}：<span style="font-size: 14px">{$user.usermoney}</span>
                    </p>
                    <p style="width: 70%;font-size: 14px">
                        USDT：<span style="font-size: 14px">{$user.sellmoney}</span>
                    </p>
                </div>

            </div>
            <div class="zj_tab" style="padding-bottom: 10px;position: relative">
                <div class="zj1">
                    <ul>
                        <a href="{:U('User/market',array('type'=>1))}">
                            <li <if condition="$type eq 1">class="zj_cur" </if>>币交易</li>
                        </a>
                        <a href="{:U('User/market',array('type'=>2))}">
                            <li <if condition="$type eq 2">class="zj_cur" </if>>USDT</li>
                        </a>

                    </ul>
                    <a style="position: absolute;right: 100px;" onclick="dosale()">我要出售</a>
                    <a style="position: absolute;right: 10px;" href="{:U('User/mymarket')}">我的交易记录</a>
                </div>

                <form action="{:U('User/market')}"  method="post" name="seform">
                    <div class="zj2">
                        <p class="zj2_text">用户名</p>
                        <p class="zj2_date">
                            <input type="text" id="username" name="username" value="{$username}"  class="form_datetime" style="width: 100%">
                        </p>
                        <p class="zj2_btn">
                            <input type="hidden" name="type" class="btn_zj" value="{$type}">
                            <input type="submit" class="btn_zj" value="">
                        </p>
                    </div>
                </form>

            </div>
                    <div class="msg_box ggxq" id="fknr" style="min-height: auto;display: none">
                        <form action="{:U('User/dosale')}"  method="post" name="myform" id="myform" style="">
                        <h3>出售信息</h3>
                        <div class="tab-content" >
                            <div  class="tab-pane active">
                                <div class="full-height-scroll">
                                    <div class="table-responsive" style="padding-bottom: 10px;padding-left: 5px">
                                        <div class="fk_ban fk_ban1" style="width: 25%;margin: 10px 0;line-height:auto">单价：</div>
                                        <div style="width: 70%;float: left;margin: 10px 0;word-break: break-all">
                                            <input type="text" name="price" id="price" placeholder="单价最多保留小数点后2位" value="" onkeyup="if(isNaN(value))execCommand('undo')" onafterpaste="if(isNaN(value))execCommand('undo')" style="width: 100%;text-indent: 3px">
                                        </div>
                                        <div class="fk_ban fk_ban1" style="width: 25%;margin: 10px 0;line-height:auto">数量：</div>
                                        <div style="width: 70%;float: left;margin: 10px 0;word-break: break-all">
                                            <input type="text" name="num" id="num" placeholder="请输入要出售的数量" value="" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" style="width: 100%;text-indent: 3px">
                                        </div>
                                        <div class="fk_ban fk_ban1" style="width: 25%;margin: 10px 0;line-height:auto">收款信息：</div>
                                        <div style="width: 70%;float: left;margin: 10px 0;word-break: break-all">
                                            <input type="text" name="msg" id="msg" readonly value="{$user.qbdz}" style="width: 100%;text-indent: 3px">
                                        </div>


                                        <if condition="$user.fuwushang eq 1">
                                            <div class="fk_ban fk_ban1" style="width: 25%;margin: 10px 0;line-height:auto">出售类型：</div>
                                            <div style="width: 70%;float: left;margin: 10px 0;word-break: break-all">
                                                <span style="display: block;width: 20px;float: left">币</span><input type="radio" name="type" value="1" checked style="float: left;margin-right: 20px">
                                                <span style="display: block;width: 40px;float: left">USDT</span><input type="radio" name="type" value="2" style="float: left">
                                            </div>
                                        </if>

                                        <div style="width: 100%;float: left">
                                            <div onclick="subthis()" style="width: 80px;float: left;margin-left: 60px;line-height: 30px;text-align: center;background: #0dae8d;color: #fff;margin-top: 20px;cursor: pointer">
                                                提交
                                            </div>
                                            <div style="width: 80px;float: right;margin-right: 60px;line-height: 30px;text-align: center;background: #0dae8d;color: #fff;margin-top: 20px;cursor: pointer" onclick="closethis()">关闭</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        </form>
                    </div>

            </div>
            <div class="clear"></div>
            <div class="fx_tab">
                <div class="table-responsive block_tab1 ">
                    <table>
                        <tr>
                            <th>用户</th>
                            <th>单价</th>
                            <th>数量</th>
                            <th>总价</th>
                            <th>操作</th>
                        </tr>
                        <foreach name="list" item="item">
                            <tr class="tab_bg">
                                <td>{$item.username}</td>
                                <td>{$item.price}</td>
                                <td>{$item.num}</td>
                                <td>{$item.total}</td>
                                <td>
                                    <if condition="$item.status eq 0">
                                        <a onclick="check_fk({$item['id']})" style="color:#0dae8d">立即购买</a>
                                        <else/>
                                        <a style="color:red">已售</a>
                                    </if>
                                </td>
                            </tr>
                            <div class="msg_box ggxq" id="fknr_{$item.id}" style="min-height: auto;display: none">
                                <h3>产品详情</h3>
                                <div class="tab-content" >
                                    <div id="" class="tab-pane active">
                                        <div class="full-height-scroll">
                                            <div class="table-responsive" style="padding-bottom: 10px;padding-left: 5px">
                                                <div class="fk_ban fk_ban1" style="width: 25%;margin: 10px 0;line-height:auto">类型：</div>
                                                <div style="width: 70%;float: left;margin: 10px 0;word-break: break-all;color: red">
                                                    <if condition="$item.type eq 1">{$B}</if>
                                                    <if condition="$item.type eq 2">USDT</if>
                                                </div>
                                                <div class="fk_ban fk_ban1" style="width: 25%;margin: 10px 0;line-height:auto">用户：</div>
                                                <div style="width: 70%;float: left;margin: 10px 0;word-break: break-all">
                                                    {$item.username}
                                                </div>
                                                <div class="fk_ban fk_ban1" style="width: 25%;margin: 10px 0;line-height:auto">单价：</div>
                                                <div style="width: 70%;float: left;margin: 10px 0;word-break: break-all">
                                                    {$item.price}
                                                </div>
                                                <div class="fk_ban fk_ban1" style="width: 25%;margin: 10px 0;line-height:auto">数量：</div>
                                                <div style="width: 70%;float: left;margin: 10px 0;word-break: break-all">
                                                    {$item.num}
                                                </div>
                                                <div class="fk_ban fk_ban1" style="width: 25%;margin: 10px 0;line-height:auto">总价：</div>
                                                <div style="width: 70%;float: left;margin: 10px 0;word-break: break-all">
                                                    {$item.total}
                                                </div>
                                                <div class="fk_ban fk_ban1" style="width: 25%;margin: 10px 0;line-height:auto">收款信息：</div>
                                                <div style="width: 70%;float: left;margin: 10px 0;word-break: break-all">
                                                    {$item.msg}
                                                </div>

                                                <div style="width: 100%;float: left">
                                                    <div style="width: 80px;float: left;margin-left: 60px;line-height: 30px;text-align: center;background: #0dae8d;color: #fff;margin-top: 20px;cursor: pointer"  <if condition="$item.status eq 0 ">onclick="buythis({$item.id})" </if>>
                                                      <if condition="$item.status eq 0 ">购买</if><if condition="$item.status eq 1">出售中</if>
                                                    </div>
                                                    <div style="width: 80px;float: right;margin-right: 60px;line-height: 30px;text-align: center;background: #0dae8d;color: #fff;margin-top: 20px;cursor: pointer" onclick="close_fk({$item.id})">关闭</div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                        </foreach>
                    </table>
                </div>
            </div>
            <script>
                function dosale(){
                    $("#fknr").show();
                    $(".fx_tab").show();
                }
                function closethis(){
                    $("#fknr").hide();
                    $(".fx_tab").show();
                }
                function check_fk(id){
                    $("#fknr_"+id).show();
                }

                function close_fk(id){
                    $("#fknr_"+id).hide();
                }
                function close_bp(){
                    $("#buy_price").hide();
                }
            </script>

            <!--分页-->
            <input type="hidden" id="page_url" value="market&status={$status}">

            <div style="line-height: 30px;float: right;margin-top: 20px" class="pages">
                <ul>
                    <li style="width: 20%;float: left;text-align: center;cursor: pointer;list-style-type: none;"><a onclick="page_up()">上一页</a></li>
                    <li style="width: 25%;float: left;text-align: center;font-size: 14px;list-style-type: none;">
                        <if condition="$count eq 0 ">0
                            <else/>
                            <input type="text" onchange="gopage({$page_all})" id="gopage" value="{$page}" style="width: 40%;border: none;background: none;text-align: right;line-height: 30px;font-size: 15px;padding-bottom: 5px;padding-right: 5px">
                        </if>
                        /{$page_all}
                    </li>
                    <li style="width: 20%;float: left;text-align: center;cursor: pointer;list-style-type: none;"><a onclick="page_down({$page_all})">下一页</a></li>
                    <li style="width: 35%;float: left;text-align: center;font-size: 14px;list-style-type: none;">共{$count}条记录</li>
                </ul>
            </div>
            <script type="text/javascript">
                function buythis(id){
                    $("#buy_price").hide();
                    confirm1("确定要进行购买吗？","{:U('User/marketbuy')}"+"&id="+id);
                }
                function subthis(){
                    var price = $("#price").val();
                    var num = $("#num").val();
                    var msg = $("#msg").val();
                    if(!price){
                        $("#price").focus();
                    }else if(!num){
                        $("#num").focus();
                    }else if(!msg){
                        $("#msg").focus();
                    }else{
                       $("#myform").submit();
                    }

                }
                var page_url = document.getElementById("page_url").value;
                function gopage(page_all){
                    var url = window.location.href;
                    var status = getQueryString('status');
                    var n=(url.split('&status='+status)).length;
                    if(n==2){
                        var url = url.replace("&status="+status,"");
                    }

                    var a = getQueryString('a');
                    url = changeURLPar(url, 'a', page_url);
                    var page = document.getElementById("gopage").value;
                    if(page <= page_all){
                        url = changeURLPar(url, 'page', page);
                        window.location.href = url
                    }else{
                        url = changeURLPar(url, 'page', page_all);
                        window.location.href = url
                    }
                }
                //下一页
                function page_down(page_all){
                    var url = window.location.href;
                    var status = getQueryString('status');
                    var n=(url.split('&status='+status)).length;
                    if(n==2){
                        var url = url.replace("&status="+status,"");
                    }
                    var page = getQueryString('page');
                    var a = getQueryString('a');
                    url = changeURLPar(url, 'a', page_url);
                    if(page_all > 1 && page == null){
                        window.location.href = url+"&page=2"
                    }else{
                        if(page < page_all){
                            page = Number(page) + Number(1);
                            url = changeURLPar(url, 'page', page);
                            window.location.href = url
                        }else{
                            window.location.href = url
                        }

                    }
                }
                //上一页
                function page_up(){
                    var url = window.location.href;
                    var status = getQueryString('status');
                    var n=(url.split('&status='+status)).length;
                    if(n==2){
                        var url = url.replace("&status="+status,"");
                    }
                    var page = getQueryString('page');
                    var a = getQueryString('a');
                    url = changeURLPar(url, 'a', page_url);
                    if(page == 1 || page == null){
                        window.location.href = url
                    }else{
                        page = Number(page) - Number(1);
                        url = changeURLPar(url, 'page', page);
                        window.location.href = url
                    }
                }
                //改url参数  destinv = url   par = 要改的参数  par_value = 新参数值
                //url = changeURLPar(url, 'page', page);
                function changeURLPar(destiny, par, par_value)
                {
                    var pattern = par+'=([^&]*)';
                    var replaceText = par+'='+par_value;
                    if (destiny.match(pattern))
                    {
                        var tmp = '/\\'+par+'=[^&]*/';
                        tmp = destiny.replace(eval(tmp), replaceText);
                        return (tmp);
                    }
                    else
                    {
                        if (destiny.match('[\?]'))
                        {
                            return destiny+'&'+ replaceText;
                        }
                        else
                        {
                            return destiny+'?'+replaceText;
                        }
                    }
                    return destiny+'\n'+par+'\n'+par_value;
                }

                //获取参数值   name=参数名
                //var page = getQueryString('page');
                function getQueryString(name) {
                    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
                    var r = window.location.search.substr(1).match(reg);
                    if (r != null) return unescape(r[2]); return null;
                }

            </script>

        </div>

    </div>
</section>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="/js/js/bootstrap.js"></script>
<script>
    // 	表单提交
    var bool = false;
    function toSubmit() {
        var name = $('#reservationName').val();
        var mobile = $('#reservationPhone').val();
        var id = $('#reservationId').val();
        // 		$('form').submit(function(){
        if ($("#endDate").val() == '') {
            showMsg('请选择离店时间！');
            bool = false;
            return bool;
        } else {
            bool = true;
        }
        if (bool) {
            var sdate = new Date($("#startDate").val());
            var edate = new Date($("#endDate").val());

        }
        // 		});
    }

    var obj;
    // var id = ${roomId};
    // var sdate = new Date();
    var sdate = '2018-07-01';
    // $.post('../hotel/roomOrder',{id:id},function(data){
    //   if(data.code==1000){
    //     if(data.result.hotelOrder.leaveTime != undefined){
    //       if(data.result.hotelOrder.leaveTime.time > new Date().getTime()){
    //         sdate = new Date(data.result.hotelOrder.leaveTime.time);
    //       }
    //     }
    //   }

    // 	alert(sdate);
    //     $.post('../hotel/reservatTime',{id:id},function(data){
    //       obj = data.result;
    obj = ['', '', '']; //禁用日期可以从数据库查
    // 	自定义格式
    $.fn.datetimepicker.dates['zdy'] = {
        days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
        daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
        daysMin: ["日", "一", "二", "三", "四", "五", "六"],
        months: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
        monthsShort: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
        today: "今天",
        format: "yyyy-mm-dd",
        titleFormat: "yyyy-mm-",
        weekStart: 1,
        suffix: [],
        meridiem: ["上午", "下午"]
    };
    $('#startDate').datetimepicker({
        language: 'zdy',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        startDate: sdate,
        minView: 2,
        maxView: 3,
        onRenderDay: function(date) {
            // 	    	alert(date);
            var date1 = date.getFullYear() + '-' +
                    (date.getMonth() < 9 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) +
                    '-' +
                    (date.getDate() < 10 ? '0' + (date.getDate() - 1) : date.getDate() - 1);
            // for(var o in obj){
            //   if(date1==obj[o]){
            //     return ['disabled'];
            //   }
            // }

        }
    }).on('changeDate', function(ev) {
        // 		alert($("#startDate").val());
        $('#endDate').datetimepicker('remove');
        $('#endDate').val('');
        var sdate = $("#startDate").val();
        var edate;
        for (var o in obj) {
            if (new Date(sdate) <= new Date(obj[o])) {
                var date = new Date(obj[o])
                var ndate = +date + 24 * 60 * 60 * 1000;
                var leaveTime = new Date(ndate);
                edate = leaveTime.getFullYear() + '-' + (leaveTime.getMonth() + 1) + '-' + leaveTime.getDate();

                break;
            }
        }
        // 			alert(edate);
        $('#endDate').datetimepicker({
            language: 'zdy',
            weekStart: 1,
            todayBtn: 1,
            autoclose: 1,
            startDate: sdate,
            endDate: edate,
            minView: 2,
            maxView: 3
        }).on('changeDate', function(ev) {
            // 		            alert(o+++"~~")
        });
    });
    // });
    // });
    $("#endDate").click(function() {
        if ($("#startDate").val() != '') {

        } else {
            showMsg('请先选择时间！');
        }
    });
</script>
<script type="text/javascript" language="javascript">
    var nav1 = document.getElementById("nav1");
    var links1 = nav1.getElementsByTagName("li");
    var lilen1 = nav1.getElementsByTagName("a");
    var currenturl1 = document.location.href;
    var last1 = 0;
    for (var i1=0;i1<links1.length;i1++)
    {
        var linkurl1 = lilen1[i1].getAttribute("href");
        if(currenturl1.indexOf(linkurl1)!=-1)
        {
            last1 = i1;
        }
    }

    links1[last1].className = "cur1";

</script>
</body>
</html>
